import pygame
from pygame.locals import *
import sys

def engine(scene):
    #start the main game loop
    scene.init()
    while 1:
       scene.loop()
       #check for events
       for event in pygame.event.get():
         if event.type == QUIT: #if you try to close the program
           sys.exit() #exit the program
         elif event.type == KEYDOWN: #you press a key
           scene.reportKey(event.key) # tell the scene what key it it
           if scene.nextscene != 0: #if theres a new scene we shuold display it
                   print "newscene"
                   scene = scene.nextscene
                   scene.nextscene = 0
                   scene.init()